package com.msti.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.msti.entity.Batch;
import com.msti.entity.Course;
import com.msti.entity.Student;
import com.msti.service.BatchMgtDAO;
import com.msti.service.BatchMgtDAOImpl;
import com.msti.service.CourseMgtDAO;
import com.msti.service.CourseMgtDAOImpl;
import com.msti.service.StudentDAO;
import com.msti.service.StudentDAOImpl;
import com.msti.utility.Utility;

/**
 * Servlet implementation class UpdateStudent
 */
public class UpdateStudent extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateStudent() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Student student = new Student();
		student.setStudentID(request.getParameter("id"));
		student.setAddress(request.getParameter("address"));
		student.setCDCNO(request.getParameter("CDCNO"));
		student.setDateOfBirth(Utility.stringToDate(request.getParameter("dateOfBirth")));
		student.setFullName(request.getParameter("fullName"));
		student.setNICNO(request.getParameter("NICNO"));
		student.setPassportNo(request.getParameter("passportNo"));
		student.setPhone(request.getParameter("phone"));
		StudentDAO studentDetail = new StudentDAOImpl();
		studentDetail.doUpdate(student);
		response.sendRedirect("index.jsp");
		
	}

}
